<template>
  <n-upload :headers="headers" @finish="onFinish" @error="onError" @update:file-list="updateFileList"
    v-bind="props.props">
    <div v-if="$slots.default">
      <slot></slot>
    </div>
  </n-upload>
</template>
<script setup lang="tsx">
import { UploadProps, useMessage } from 'naive-ui';
import { useMainStore } from '@/store';

const mainStore = useMainStore();
const message = useMessage();

let props = defineProps<{
  props: UploadProps,
}>();

const headers = { 'X-TOKEN': mainStore.token };
const onFinish = () => {
  message.success('上传成功')
}
const onError = () => {
  message.warning('上传失败')
}
const updateFileList = (list) => {
  console.log(list)
}
</script>